/* 
 * File:   JStubArgument.h
 * Author: johnneyshi
 *
 * Created on 2013年5月14日, 下午8:31
 */

#ifndef JSTUBARGUMENT_H
#define	JSTUBARGUMENT_H
#include "JInOutPut.h"
#include "JSerialize.h"

class JStubArgument 
{
public:
    JStubArgument();
    virtual ~JStubArgument();
    virtual int PackStubMessage(JInOutPut& _strea,int& _allSize) = 0;
    virtual int UnPackStubMessage(JInOutPut& _strea) = 0;
    /*表示要序列化的函数名，参数类型*/
    static void PackStubMessageHead(JInOutPut& strea,int& selfSize,int& classSize,std::string _funcName,std::list<std::string> _args)
    {
        JSerialize::PutInt(strea,classSize,selfSize);
        JSerialize::Serialize(strea,_funcName,classSize);
        JSerialize::Serialize(strea,_args,classSize);
    }
    //返回selfSize
    static int PackStubMessageTail(JInOutPut& strea,int& selfSize, int& classSize) 
    {
        selfSize += classSize;
        JSerialize::Verify(strea, classSize, -1 * selfSize);
        return selfSize;
    }
    static int UnPackStubMessageHead(JInOutPut& strea,std::string& _funcName,std::list<std::string>& _args) 
    {
        int classSize = JSerialize::GetInt(strea, sizeof (int));
        _funcName = JSerialize::ReSerializeString(strea);
        _args = JSerialize::ReSerializeStringList(strea);
        return classSize;
    }
    static JStubArgument* StubArgumentFactory(JInOutPut& _strea,std::string _arg);
private:
    
};

#endif	/* JSTUBARGUMENT_H */

